<template>
    <div class="ground" ref="ground">

    </div>
</template>

<script>
    // 引入echarts
    import echarts from 'echarts'
    export default {
        name: "Ground",
        props: {
            data: {
                type: Array
            }
        },
        data() {
            return {
                // data1: []
            }
        },
        mounted() {},
        watch: {
            data: function (val) {

                // console.log(val);
                // this.data1 = val
                this.drawLine()
                return val
            }
        },
        methods: {
            drawLine() {
                // 基于准备好的dom，初始化echarts实例
                let a = this.$refs.ground
                let myChart = this.$echarts.init(a)
                // 绘制图表
                myChart.setOption({
                    color: ['red', '#3bcec6', 'red', '#3bcec6', 'red'],
                    title: {
                        text: '在Vue中使用echarts'
                    },
                    tooltip: {},
                    xAxis: {
                        data: this.data
                    },
                    yAxis: {},
                    series: [{
                        name: '销量',
                        type: 'bar',
                        data: [5, 20, 36, 10, 10, 20]
                    }]
                });
            }
        }
    }
</script>

<style>

</style>